<?php
/**
 * FastApp.
 * 8/18/24
 * @Author 深色的海 (wx:deepsea_0024)
 * @Contact telegram:deepsea159 
 */

namespace App\Marketing\Api\Controller;

use App\Fastapp\Api\Controller\ApiController;
use App\Marketing\Api\Service\BoxService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Psr\Http\Message\ResponseInterface;

#[Controller('api/marketing/box')]
class BoxController extends ApiController
{

    #[Inject]
    public BoxService $service;

    #[GetMapping('list')]
    public function list(): ResponseInterface
    {
        return $this->success($this->service->list($this->request->input('code')));
    }

    #[GetMapping('log')]
    public function log(): ResponseInterface
    {
        return $this->success($this->service->log($this->request->input('code')));
    }

    #[GetMapping('userLog')]
    public function userLog(): ResponseInterface
    {
        return $this->success($this->service->userLog($this->request->input('code')));
    }

    #[PostMapping('open')]
    public function open(): ResponseInterface
    {
        return $this->success($this->service->open($this->validate([
            'id' => 'required|integer',
            'num' => 'required|integer|min:1|max:10',
        ])));
    }
}